/*
 * @lc app=leetcode.cn id=118 lang=javascript
 *
 * [118] 杨辉三角
 */

// @lc code=start
/**
 * @param {number} numRows
 * @return {number[][]}
 */
var generate = function(numRows) {
  let dp = Array.from({length: numRows}, () => [])
  for (let i = 0; i < numRows; i++) {
    dp[i][0] = dp[i][i] = 1
  }
  for (let j = 0; j < numRows; j++) {
    let i = j
    while (i) {
      if (i !== 0 && i !== j) {
        dp[j][i] = dp[j-1][i-1] + dp[j-1][i]
      }
      i--
    }
  }
  return dp
};
// @lc code=end

